package com.cetc;

import org.junit.Test;

import java.net.InetAddress;
import java.net.UnknownHostException;

/**
 * @Classname InetAdress
 * @Description InetAdress方法测试
 * @Date 2022/11/25 17:19
 * @Created by louzhuangxi
 */
public class InetAddressTest {
    @Test
    public void test01(){
        try {
            InetAddress inet1 = InetAddress.getByName("127.0.0.1");
            System.out.println(inet1);
            InetAddress inet2 = InetAddress.getByName("www.baidu.com");
            System.out.println(inet2);
            InetAddress inet3 = InetAddress.getByName("127.0.0.1");
            System.out.println(inet3);
            InetAddress inet4 = InetAddress.getByName("localhost");
            System.out.println(inet4);
            InetAddress inet5 = InetAddress.getLocalHost();
            System.out.println(inet5);
            System.out.println(inet2.getHostAddress());
            System.out.println(inet2.getHostName());
        } catch (UnknownHostException e) {
            e.printStackTrace();
        }
    }
}
